package leecode

import "container/list"

func decorateRecord(root *TreeNode) (result []int) {
	//层序遍历
	queue := list.New()
	if root == nil {
		return
	}
	queue.PushBack(root)
	result = append(result, root.Val)
	for queue.Len() > 0 {
		size := queue.Len()
		for i := 0; i < size; i++ {
			//当前节点
			node := queue.Remove(queue.Front()).(*TreeNode)
			if node.Left != nil {
				queue.PushBack(node.Left)
				result = append(result, node.Left.Val)
			}
			if node.Right != nil {
				queue.PushBack(node.Right)
				result = append(result, node.Right.Val)
			}
		}
	}
	return
}
